<template>
    <view>
        <view class="load" v-if="!load">
            <u-loading-icon mode="circle" inactive-color="#fff" text="正在加载..." vertical></u-loading-icon>
        </view>
        <block v-else>
            <view class="loacl_box">

                <block v-if="pa_list.length">
                    <view class="heatbox" v-for="(item, index) in pa_list" :key="index" @click="nav_to('/pages/store/pa_finance?id=' + item.PlaceID)">
                        <view class="heattextbox">
                            <image class="heat_img"
                                src="https://giftapp.oss-cn-shenzhen.aliyuncs.com/upload/17329525852691481.png"></image>
                            <view class="heat_til">{{ item.PlaceName }}</view>
                            <view class="heat_more"> {{ item.Province }} · {{ item.City }}</view>
                        </view>
                        <view class="heat_shop_box">
                            <view class="detBox">
                                <view class="detailInfo">
                                    <view class="detailNum">{{ formatNumber(item.PlaceSaleData.CurrentMonthSaleMoney) }}</view>
                                    <view class="detailtext">本月销售额</view>
                                </view>
                            </view>
                            <view class="detBox">
                                <view class="detailInfo">
                                    <view class="detailNum">{{ formatNumber(item.PlaceSaleData.CurrentMonthSaleQty) }}</view>
                                    <view class="detailtext">本月销售量</view>
                                </view>
                            </view>
                            <view class="detBox">
                                <view class="detailInfo">
                                    <view class="detailNum">{{ formatNumber(item.PlaceSaleData.TotalSaleMoney) }}</view>
                                    <view class="detailtext">累计销售额</view>
                                </view>
                            </view>
                            <view class="detBox">
                                <view class="detailInfo">
                                    <view class="detailNum">{{ formatNumber(item.PlaceSaleData.TotalSaleQty) }}</view>
                                    <view class="detailtext">累计销售量</view>
                                </view>
                            </view>

                        </view>
                    </view>

                </block>

                <EmptyBox class="nullbox" v-else text="未找到该场馆..."></EmptyBox>
                <BtmLogo></BtmLogo>
            </view>
        </block>
    </view>
</template>

<script>
import topStatus from '@/components/topStatus/topStatus.vue';
export default {
    components: {
        topStatus
    },
    data() {
        return {
            load: false,
            PageIndex: 1,
            PageSize: 10,
            pa_list: [],
            isMore: true,
            searchContent: '',

            homeEntry: [],
            myHomeTown: ''
        };
    },
    onLoad() {
        this.init()
    },
    onShow() {

    },
    onReachBottom() {
        if (this.isMore) {
            this.PageIndex++;
            this.localList();
        }
    },
    methods: {
        getPayCount(item) {
            return item > 1000 ? (item / 1000).toFixed(1) + 'k' : item > 1000000 ? (item / 1000000).toFixed(1) + 'M' : item > 100000000 ? (item / 100000000).toFixed(1) : item
        },
        formatNumber(e) {
            let num = Number(e);
            if (num > 990000) {
                // 将数字转换为“万”单位，并保留一位小数
                const wan = (num / 10000).toFixed(1);
                return `${wan}万`;
            } else {
                // 如果数字小于等于99万，直接返回原数字
                return num.toString();
            }
        },
        async init() {
            this.localList()
        },
        // 点击跳转详情
        goDetail(id) {
            this.nav_to(`/pages/shop/detail?id=${id}`)
        },
        async localList() {
            let res = await this.$api.post('Dealer/PlacePartner', {
                // PageIndex: this.PageIndex,
                // PageSize: this.PageSize,
                // PlaceName: this.searchContent,
            })
            if (res.code == 0) {
                this.pa_list = this.PageIndex == 1 ? res.data : this.pa_list.concat(res.data)
                this.isMore = Array.isArray(res.data) && res.data.length >= this.PageSize;
                this.load = true
            }
        },
        subSearch() {
            this.PageIndex = 1
            // this.isSearch = true
            // this.searchLoding = true
            this.localList();
        },
        subblur() {
            this.PageIndex = 1
            // this.isSearch = true
            // this.searchLoding = true
            this.localList();
        },
    },
}
</script>
<style lang='scss'>
page {
    background: linear-gradient(159deg, #D13D19 0%, #A60C0A 100%);
}

.nullbox {
    view {
        color: #ccc !important;
    }
}


.loacl_box {
    width: 100%;
    padding: 0 20rpx;
    padding-bottom: 100rpx;



    .heatbox {
        width: 100%;
        margin: 20rpx auto;
        background-image: url('https://giftapp.oss-cn-shenzhen.aliyuncs.com/upload/17325278470281311.png');
        background-size: cover;
        background-repeat: no-repeat;
        border-radius: 18rpx;
        padding-bottom: 26rpx;

        .heattextbox {
            display: flex;
            align-items: center;
            width: 100%;
            padding: 26rpx 22rpx;
            box-sizing: border-box;

            .heat_til {
                font-size: 32rpx;
                font-weight: bold;
                margin-right: 8rpx;
            }

            .heat_img {
                width: 38rpx;
                height: 38rpx;
								min-width: 38rpx;
								margin-right: 8rpx;
            }

            .heat_more {
                width: fit-content;
								min-width: fit-content;
                height: 44rpx;
                padding: 0 24rpx;
                background: linear-gradient(90deg, rgba(250, 113, 52, 0.05) 0%, rgba(253, 151, 74, 0.21) 100%);
                border-radius: 24rpx;
                display: flex;
                align-items: center;
                justify-content: center;
                font-size: 24rpx;
                color: #FF6030;
                margin-left: auto;
            }
        }

        .heat_shop_box {
            width: 100%;
            padding: 0 22rpx;
            box-sizing: border-box;
            display: flex;
            align-items: center;

            .detBox {
                width: 25%;
                display: flex;
                justify-content: center;
                align-items: center;
            }

            .detailInfo {
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;

                .detailNum {
                    font-size: 38rpx;
                    font-weight: bold;
                    color: #ff6030;
                }

                .detailtext {
                    margin-top: 10rpx;
                    font-size: 24rpx;
                    color: #666666;
                }
            }

        }
    }
}
</style>